function C_prepareNI(ID,Trigger)

global CG;

if nargin<2 Trigger = 'internal'; end
if nargin<1 ID = 1; end

% REMOVE THE DATA OF THE CURRENT AUDIOIN ACQUISITION
CG.Data.NI(ID).Time = double([]);
CG.Data.NI(ID).Analog = single([]);
CG.Events.NI(ID).Events = struct('Name',{},'Data',{},'Time',{});
CG.Sessions.NI(ID).Iteration = 0;
CG.Sessions.NI(ID).LastSavedPacket = 0;
CG.Sessions.NI(ID).LastSavedEvent = 0;
CG.Sessions.NI(ID).PacketsAcquired = 0;
CG.Sessions.NI(ID).CurrentSize = 0;
CG.Sessions.NI(ID).LastTime = 0;

if ~isfield(CG,'Sessions') | ~isfield(CG.Sessions,'NI')
  C_createNI;
end

if CG.Sessions.NI(ID).SAI.IsRunning
  C_stopNI(ID,0); % Stop without saving
end

% UPDATE PARAMETERS
[Pars,PS] = C_getParametersModule('ModuleType','NI','IDType',ID);
C_setSRNI(ID,PS.SRAI,'SAI');
ControlSamples = floor(PS.SRAI*PS.ControlInterval);
CG.Display.NI(ID).DisplayDuration = PS.DisplayDuration;
set(CG.Sessions.NI(ID).SAI,'NotifyWhenDataAvailableExceeds',ControlSamples);

C_Logger('C_prepareNI','NI starting...\n');
try set(CG.GUI.Main.Modules.NI(ID).StartButton,'Value',0,'BackgroundColor',[0,1,0]); end